﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using QuanLyBongDa.HeThongGiaoDien;
using QuanLyBongDa.HeThongLuuTru;
using QuanLyBongDa.HeThongXuLy;

namespace QuanLyBongDa.HeThongLuuTru
{
    class DoiBong
    {
        public static bool ThemDoiBong(DoiBongDTO db)
        {
            try
            {
                string sql = "insert into DOIBONG(TenDoiBong, TenSanNha, MaSanNha, HuanLuanVien) values ('" + db.TenDoiBong + "','" + db.TenSanNha + "','" + db.MaSanNha + "','" + db.HuanLuanVien + "')";
                DataAccess.ExecNonQuery(sql);
                return true;

            }
            catch (Exception)
            {
                //MessageBox.Show(ex.ToString());
                return false;
            }
        }
        public static DataTable DanhSachDoiBong()
        {
            string sql = "SELECT* FROM DOIBONG";
            return DataAccess.ExecQuery(sql);
        }
        public static bool SuaDoiBong(DoiBongDTO db)
        {
            try
            {
                string sql = "Update DOIBONG set TenDoiBong = '" + db.TenDoiBong + "',TenSanNha = '" + db.TenSanNha + "',MaSanNha = '" + db.MaSanNha + "',HuanLuanVien = '" + db.HuanLuanVien + "' where MaDoiBong = " + db.MaDoiBong;
                DataAccess.ExecNonQuery(sql);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public static bool XoaDoiBong(DoiBongDTO db)
        {
            try
            {
                string sql = "Delete from DOIBONG where MaDoiBong = " + db.MaDoiBong;
                DataAccess.ExecNonQuery(sql);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}